package ru.amse.tsyganov.jumleditor.commands;

import java.util.List;

import ru.amse.tsyganov.jumleditor.model.common.Edge;
import ru.amse.tsyganov.jumleditor.model.common.GraphModel;
import ru.amse.tsyganov.jumleditor.model.common.State;
import ru.amse.tsyganov.jumleditor.properties.Property;
import ru.amse.tsyganov.jumleditor.view.ConnectionPoint;
import ru.amse.tsyganov.jumleditor.view.common.EdgeView;
import ru.amse.tsyganov.jumleditor.view.common.GraphView;
import ru.amse.tsyganov.jumleditor.view.common.StateView;
import ru.amse.tsyganov.jumleditor.view.lines.Line;

public class CommandFactory {
	
	public static Command createMoveStateCommand(
			StateView<? extends State> stateView,
			int moveToX, int moveToY) {
		
		return new MoveStateCommand(stateView, moveToX, moveToY, true);
	}
	
	public static Command createResizeStateCommand(
			StateView<? extends State> resizingState, 
			int moveToX, int moveToY, int newWidth, int newHeight) {
		
		return new ResizeStateCommand(resizingState, 
				moveToX, moveToY, newWidth, newHeight);
	}
	
	public static Command createNewStateCommand(
			GraphView<? extends GraphModel> activityGraphView,
			StateView<? extends State> stateView) {
		
		return new NewStateCommand(activityGraphView, stateView);
	}
	
	public static Command createDeleteStateCommand(
			GraphView<? extends GraphModel> activityGraphView,
			StateView<? extends State> stateView) {
		
		return new DeleteStateCommand(activityGraphView, stateView);
	}
	
	public static Command createNewEdgeCommand(
			EdgeView<? extends Edge> edgeView) {
		
		return new NewEdgeCommand(edgeView);
	}
	
	public static <T extends Edge> Command createDeleteEdgeCommand(
			EdgeView<T> t) {
		
		return new DeleteEdgeCommand<T>(t);
	}
	
	public static Command createMoveEdgeCommand(
			EdgeView<? extends Edge> movingEdge, 
			ConnectionPoint newSourceConnectionPoint, 
			ConnectionPoint newTargetConnectionPoint) {
		
		return new MoveEdgeCommand(movingEdge, 
				newSourceConnectionPoint, newTargetConnectionPoint);
	}
	
	public static Command createMoveVerticalLineCommand(
			Line line, int newX1, int newX2) {
		
		return new MoveVerticalLineCommand(line, newX1, newX2);
	}
	
	public static Command createMoveHorizonalLineCommand(
			Line line, int newY1, int newY2) {
		
		return new MoveHorizontalLineCommand(line, newY1, newY2);
	}
	
	public static Command createCompositeCommand(
			List<? extends Command> commandList) {
		
		return new CompositeCommand(commandList);
	}
	
	public static Command createChangePropertyCommand(
			Property property, Object newValue) {
		
		return new ChangePropertyCommand(property, newValue);
	}
}
